import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
testCase = "DBshop012_搜索商品"

# 实例化浏览器对象 打开指定网站
driver = openBrowser(urlAdmin)
# 后台登录
DBshopLoginAdmin(driver)
# 点击添加商品
driver.find_element_by_xpath("(//a[@class = 'btn btn-primary'])[6]").click()
# 输入框中输入"美的"
driver.find_element_by_xpath("//input[@name = 'goods_name']").send_keys("美的")
driver.find_element_by_xpath("(//button)[1]").click()

s = driver.find_element_by_xpath("//body").text
l = "商品数\："
r = "\)"
num1 = reGetString(s,l,r)

# 判断
if num1 == "1":
    writeLog("%s 测试通过" % (testCase))
else:
    writeLog("%s 测试失败" % (testCase))
    getPhoto(driver)
driver.quit()
